package com.squirrel.common.domain;

import com.alibaba.fastjson.JSONObject;
import com.squirrel.common.param.danmu.SendParam;
import lombok.extern.slf4j.Slf4j;
import javax.websocket.EncodeException;
import javax.websocket.Encoder;
import javax.websocket.EndpointConfig;

@Slf4j
public class ServerEncoder implements Encoder.Text<SendParam> {
//    private static final Logger log = LoggerFactory.getLogger(ServerEncoder.class);

    @Override
    public String encode(SendParam sendParam) throws EncodeException {
        try {
            return JSONObject.toJSONString(sendParam);
        } catch (Exception e) {
            log.error("", e);
        }
        return null;
    }

    @Override
    public void init(EndpointConfig endpointConfig) {
        //可忽略
    }

    @Override
    public void destroy() {
        //可忽略
    }
}

